# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=rsactftool
pkgver=1169.370cb43
pkgrel=1
epoch=1
pkgdesc='RSA tool for ctf - retrieve private key from weak public key and/or uncipher data.'
groups=('blackarch' 'blackarch-crypto' 'blackarch-cracker')
arch=('any')
url='https://github.com/Ganapati/RsaCtfTool'
license=('custom:unknown')
depends=('python' 'python-sympy' 'python-gmpy2' 'python-cryptography'
         'python-requests' 'python-pycryptodome' 'python-six' 'python-urllib3'
         'python-tqdm' 'python-z3-solver' 'python-bitarray' 'python-egcd'
         'python-psutil')
makedepends=('git')
source=("$pkgname::git+https://github.com/Ganapati/RsaCtfTool.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  ( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
      sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  rm README.md

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
exec python /usr/share/$pkgname/RsaCtfTool.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

